package com.woniuxy.common.mapper;

import com.woniuxy.common.entity.MarketCommodity;
import com.woniuxy.common.entity.MarketCommodityExample;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface MarketCommodityMapper {
    int countByExample(MarketCommodityExample example);

    int deleteByExample(MarketCommodityExample example);

    int deleteByPrimaryKey(String id);

    int insert(MarketCommodity record);

    int insertSelective(MarketCommodity record);

    List<MarketCommodity> selectByExample(MarketCommodityExample example);

    MarketCommodity selectByPrimaryKey(String id);

    int updateByExampleSelective(@Param("record") MarketCommodity record, @Param("example") MarketCommodityExample example);

    int updateByExample(@Param("record") MarketCommodity record, @Param("example") MarketCommodityExample example);

    int updateByPrimaryKeySelective(MarketCommodity record);

    int updateByPrimaryKey(MarketCommodity record);

	@Select("select * from market_commodity where status=0")
    List<MarketCommodity> selectAllCommodity();

    @Select("select * from market_commodity where status!=2 and user_id=#{userid} order by date DESC")
    List<MarketCommodity> selectAllCommodityByUserId(String userid);

    @Select("select * from market_commodity where status=0 and title like  #{search} order by heat DESC")
    List<MarketCommodity> selectCommoditesBySearch(@Param("search") String search);

    @Select("select * from market_commodity where status=0 and user_id=#{loginuserid} order by date DESC")
    List<MarketCommodity> selectIReLease(String loginuserid);

    @Select("select * from market_commodity where status=1 and user_id=#{loginuserid} order by date DESC")
    List<MarketCommodity> selectISell(String loginuserid);

    @Update("update market_commodity set status=2 where id=#{commodityid}")
    int deleteById(String commodityid);

    @Update("update market_commodity set heat=heat+1,heat_status=1 where id=#{commodityid}")
    int updateHeatStatusByPrimaryKey(String commodityid);

    @Update("update market_commodity set status=1 where id=#{commodityId}")
    int updateStatusById(String commodityId);

    @Update("UPDATE market_commodity set heat_status=0 where heat_status =1")
    int updateCommodityHeatStatus();
}